<?php
/**
 *title
 * @author: lican<364548233@qq.com>
 *Date: 2021/1/8
 *Time: 16:29
 */

namespace App\Http\Services;

use App\Jobs\UpdateSchoolJob;
use App\Models\School;
use Carbon\Carbon;

class AppService{

    /**
     *关闭应用
     * @author: lican<364548233@qq.com>
     */
    public static function close($schoolCode){
        //donothing

        return MsgService::getInterfaceMsg(0);
    }

    /**
     *开启应用
     * @author: lican<364548233@qq.com>
     */
    public static function open($schoolCode, $host = ApiService::OPEN_WECARD_DOMAIN){
        if($schoolCode == "4111010001"){
            return MsgService::getInterfaceMsg(0, [
                'manage_url' => '',
                'url' => ''
            ]);
        }
        $updateSchoolJon = (new UpdateSchoolJob($schoolCode, $host));
        dispatch($updateSchoolJon);
        //通过部署域名，是否私有化，主体来源来确定PC端地址
        $userPcAuthUri = AuthService::getUserPcAuthUri($schoolCode, ApiService::APP_KEY);

        //通过部署域名，是否私有化，主体来源确定
        $userH5AuthUri = AuthService::getUserH5AuthUri($schoolCode, ApiService::APP_KEY);

        return MsgService::getInterfaceMsg(0, [
            'manage_url' => $userPcAuthUri,
            'url' => $userH5AuthUri
        ]);

    }

}
